package swings.others;

import javax.swing.*;

/**
 * @version V1.0
 * @Title:
 * @Package
 * @Description:
 * @author: runoob
 * @date:
 */
public class CommonScrollPane extends JScrollPane {
    
    public CommonScrollPane(int x, int y, int width, int height){
        JScrollBar scrollBar = new JScrollBar(JScrollBar.VERTICAL) {
            @Override
            public boolean isVisible() {
                return true;
            }
        };
        //设置滚动速度
        scrollBar.setUnitIncrement(20);
        this.setVerticalScrollBar(scrollBar);
        this.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
        this.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        this.setBounds(x,y,width,height);
        this.setOpaque(false);
        this.getViewport().setOpaque(false);
        this.setBorder(null);
        this.getVerticalScrollBar().setUI(new CommonScrollBarUI());
        this.getHorizontalScrollBar().setUI(new CommonScrollBarUI());
//        this.getViewport().add(recordPanel);
        this.validate();
    }
    
}
